import Vue from 'vue'
import Vuex from 'vuex'
import Router from 'vue-router'
import _ from 'lodash'
Vue.use(Vuex);
Vue.use(Router);
const store = new Vuex.Store({
  state:{
    tabs:[]
  },
  mutations:{
    addTabs(state,tab) {
      //判断先增的tab是否已经存在
      let existTab = _.filter(state.tabs,function(item){
        return item.name === tab.name
      });
      if (existTab.length == 0) {
        state.tabs.push(tab);
      }
    },
    removeTabs(state,name) {
      state.tabs = _.filter(state.tabs,function(tab){
        return !(tab.name === name);
      });
    }
  }
});
export default store;
